ostbuild: Rename shadow-repo-init -> init
authorColin Walters <walters@verbum.org>
Wed, 2 May 2012 11:55:11 +0000 (07:55 -0400)
committerColin Walters <walters@verbum.org>
Fri, 4 May 2012 20:16:16 +0000 (16:16 -0400)
Makefile-ostbuild.am
src/ostbuild/pyostbuild/builtin_init.py [new file with mode: 0755]
src/ostbuild/pyostbuild/builtin_shadow_repo_init.py [deleted file]
src/ostbuild/pyostbuild/main.py

index 4069558274d0438c725f2af4a73495edaa4e4c02..b561a28d73e2fbd9886b3710b9a075f13d6f63f1 100644 (file)
@@ -35,7 +35,7 @@ pyostbuild_PYTHON =                                   \
        src/ostbuild/pyostbuild/builtin_resolve.py      \
        src/ostbuild/pyostbuild/builtin_modify_snapshot.py      \
        src/ostbuild/pyostbuild/builtin_tree_to_bin.py  \
-       src/ostbuild/pyostbuild/builtin_shadow_repo_init.py     \
+       src/ostbuild/pyostbuild/builtin_init.py \
        src/ostbuild/pyostbuild/builtin_status.py       \
        src/ostbuild/pyostbuild/builtins.py             \
        src/ostbuild/pyostbuild/filemonitor.py          \
diff --git a/src/ostbuild/pyostbuild/builtin_init.py b/src/ostbuild/pyostbuild/builtin_init.py
new file mode 100755 (executable)
index 0000000..de45eb4
--- /dev/null
@@ -0,0 +1,58 @@
+# Copyright (C) 2012 Colin Walters <walters@verbum.org>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+import os,sys,stat,subprocess,tempfile,re,shutil
+from StringIO import StringIO
+import json
+import select,time
+import argparse
+
+from . import builtins
+from . import ostbuildrc
+from .ostbuildlog import log, fatal
+from . import fileutil
+from .subprocess_helpers import run_sync, run_sync_get_output
+
+class OstbuildInit(builtins.Builtin):
+    name = "init"
+    short_description = "Initialize working state"
+
+    def __init__(self):
+        builtins.Builtin.__init__(self)
+
+    def execute(self, argv):
+        parser = argparse.ArgumentParser(description=self.short_description)
+
+        args = parser.parse_args(argv)
+        
+        mirrordir = os.path.expanduser(ostbuildrc.get_key('mirrordir'))
+        fileutil.ensure_dir(mirrordir)
+        workdir = os.path.expanduser(ostbuildrc.get_key('workdir'))
+        fileutil.ensure_dir(workdir)
+
+        self.parse_config()
+
+        path = os.path.join(self.workdir, 'shadow-repo')
+        fileutil.ensure_dir(path)
+        if os.path.isdir(os.path.join(path, 'objects')):
+            log("note: shadow repository '%s' already exists" % (path, ))
+        else:
+            run_sync(['ostree', '--repo=' + path, 'init', '--archive'])
+            run_sync(['ostree', '--repo=' + path, 'config', 'set', 'core.parent', '/ostree/repo'])
+            log("Created shadow repository: %s" % (path, ))
+    
+builtins.register(OstbuildInit)
diff --git a/src/ostbuild/pyostbuild/builtin_shadow_repo_init.py b/src/ostbuild/pyostbuild/builtin_shadow_repo_init.py
deleted file mode 100755 (executable)
index 03211d2..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-# Copyright (C) 2012 Colin Walters <walters@verbum.org>
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the
-# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
-import os,sys,stat,subprocess,tempfile,re,shutil
-from StringIO import StringIO
-import json
-import select,time
-import argparse
-
-from . import builtins
-from .ostbuildlog import log, fatal
-from . import fileutil
-from .subprocess_helpers import run_sync, run_sync_get_output
-
-class OstbuildShadowRepoInit(builtins.Builtin):
-    name = "shadow-repo-init"
-    short_description = "Initialize a user-mode shadow repository for /ostree/repo"
-
-    def __init__(self):
-        builtins.Builtin.__init__(self)
-
-    def execute(self, argv):
-        parser = argparse.ArgumentParser(description=self.short_description)
-
-        args = parser.parse_args(argv)
-        
-        self.parse_config()
-
-        path = os.path.join(self.workdir, 'shadow-repo')
-        fileutil.ensure_dir(path)
-        if os.path.isdir(os.path.join(path, 'objects')):
-            log("Shadow repository '%s' appears to already exist" % (path, ))
-        else:
-            run_sync(['ostree', '--repo=' + path, 'init', '--archive'])
-            run_sync(['ostree', '--repo=' + path, 'config', 'set', 'core.parent', '/ostree/repo'])
-            log("Created shadow repository: %s" % (path, ))
-    
-builtins.register(OstbuildShadowRepoInit)
index 8437769c7b198f6e11ed22cc3a11f34ec4a3f9eb..488a563124b6392977f75c486174af610770a24f 100755 (executable)
@@ -35,7 +35,7 @@ from . import builtin_prefix
 from . import builtin_resolve
 from . import builtin_modify_snapshot
 from . import builtin_tree_to_bin
-from . import builtin_shadow_repo_init
+from . import builtin_init
 from . import builtin_status
 
 def usage(ecode):